RealtimeService

Constructors

Link copied to clipboard
constructor(client: PocketbaseClient)

Types

Link copied to clipboard
@Serializable
data class MessageData(val action: RealtimeService.RealtimeActionType, val record: JsonElement?)

The data sent when a realtime event is emitted

Link copied to clipboard

The type of realtime event emitted

Properties

Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard
fun connect()

Creates a realtime connection NOTE: There can only be one realtime connection going at once

Link copied to clipboard
suspend fun disconnect()

Disconnects from the current realtime session,closes all active listen coroutines and unsubscribes from all records.

Link copied to clipboard
suspend fun listen(callback: RealtimeService.MessageData.() -> Unit)

Listens for subscribed realtime events asynchronously, when one is received callback is run

Link copied to clipboard
suspend fun subscribe(delay: Long = 2000, vararg subscriptionList: String)
suspend fun subscribe(subscription: String, delay: Long = 2000)

Creates a subscription to a record or collection allowing listen to received events from the desired target.

Link copied to clipboard
suspend fun unsubscribe(delay: Long = 2000, vararg subscriptionList: String)

Removes a subscriptions to a record or collection allowing listen to no longer receive events from the desired target.

suspend fun unsubscribe(subscription: String, delay: Long = 2000)

Removes a subscription to a record or collection allowing listen to no longer receive events from the desired target.

Link copied to clipboard
suspend fun unsubscribeAll(delay: Long = 2000)

Unsubscribes from every subscription, meaning the listen no longer receives events from any collection or record until one is subscribed to